<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>随机不重复_脚本之家_www.jb51.net</title>
		<script type="text/javascript">
			var arr=[];
			var count = 5;
			var original = new Array; //原始数组 
			//给原始数组original赋值 
			for(var i = 0; i < count; i++) {
				original[i] = i + 1;
			}
			console.log(original)
			for(var num, i = 0; i < count; i++) {
				do {
					num = Math.floor(Math.random() * count);
				} while (original[num] == null);
				console.log(num)
				arr.push(original[num]);
				original[num] = null;
			}
			console.log(arr)
		</script>
	</head>

	<body>
	</body>

</html>